﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class registered : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strEmail = this.email.Text.Trim();
        string strPwd = this.password.Text.Trim();
        string strPwd2 = this.password2.Text.Trim();
        string strLoginName = this.username.Text.Trim();
        string strCheckCode = this.validateCode.Text.ToUpper().Trim();

        if (strEmail == "")
        {
            this.lblMsg.Text = "电子邮箱不能为空";
            return;
        }
        if (strLoginName == "")
        {
            this.lblMsg.Text = "登录名不能为空";
            return;
        }
        
        if(Response.Cookies["CheckCode"]==null)
        {
            this.lblMsg.Text = "验证码输入有误";
            return;
        }
        string strCookie = Request.Cookies.Get("CheckCode").Value;
        if (strCheckCode != strCookie)
        {
            this.lblMsg.Text = "验证码输入有误";
            return;
        }
        OTS.BLL.CustomBLL bll = new OTS.BLL.CustomBLL();
        if(bll.IsExistUserName(strLoginName))
        {
            this.lblMsg.Text = "该用户名已存在";
            this.username.Text = "";
            return;
        }
        OTS.Model.custom model = new OTS.Model.custom();

        model.cusEmail = strEmail;
        model.cusLoginName = strLoginName;
        model.cusPassword = strPwd;
        if (bll.Add(model))
        {
            OTS.Common.Jscript.AlertAndRedirect("注册成功！", "login.aspx");

        }

    }
}
